package com.hejing.接口interface.接口案例01;

/**
 * ClassName: EatableTest
 * Package: com.hejing.接口interface.接口案例
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-30 19:14
 * @Version: 1.0
 */
public class EatableTest {
    public static void main(String[] args) {
        Eatable[] eatables = new Eatable[3];  // 只是指明元素类型，而非new出 "接口对象"
        // 接口指向实现类对象
        eatables[0] = new Chinese();
        eatables[1] = new American();
        eatables[2] = new Indian();

        for(int i = 0; i < eatables.length; i++) {
            eatables[i].eat();
        }
    }
}




























